THE FORMAT OF C

Format of C
  • Statements are terminated with semicolons
  • Indentation is ignored by the compiler
  • C is case sensitive – all Keywords and Standard Library functions are in lowercase
  • Strings are placed in double quotes
  • Newlines are handled via \n.
  • Programs are capable of flagging success or error, those forgetting to do so have one or other chosen randomly!

Semicolons:

Semicolons are very important in C. They from a statement terminator – they tell the compiler where one statement ends and the next one begins. If you fail to place one after each statement, you will get compilation errors.

Free Format:

The spaces and tabs are ignored and can be easily placed any where.

Case Sensitivity:

Compiler will give the compilation error if it finds “Int”, “INT” or any other variation will in int because C is a case sensitive language. All of the 40 or so C Keywords are in lowercase.

Variables:

  • Variables must be declared before use immediately after “{“
  • Valid characters are letters, digits and “_”
  • First character cannot be a digit.
  • 31 characters recognized for local variables (More can be used, but are ignored).
  • Some implementations recognized only 6 characters in global variables (and function names)!
  • Upper and lower case letters are distinct.

Note:- When a variable is declared it is given a type. this type defines its size and how it may be used. Similarly when a constant is specified the compiler gives it a type.

printf and scanf:

  • printf writes integer values to screen when %i is used.
  • scanf reads integer values from the keyboard when %i is used.
  • “&” VERY important with scanf (required to change the parameter, this will be investigated later) – absence will make program very ill.
  • “&” not necessary with printf because current value of parameter is used.

Related posts